import request from '@/utils/request'
import type { ApiRes } from '@/types/data'
import type { Goods, goodsQuery } from '@/types/goods'

//商品分类
export const getCategory = () => {
  return request<ApiRes<string[]>>({
    url: 'pro/getCategory'
  })
}
//分页获取商品列表
export const getGoodsList = (params: goodsQuery) => {
  return request<ApiRes<{ total: number; items: Goods[] }>>({
    url: 'pro/list',
    params
  })
}
//
export const changeStatus = (
  proid: string,
  type: 'issale' | 'isseckill' | 'isrecommend',
  state: 0 | 1
) => {
  return request<ApiRes<string>>({
    url: 'pro/updateFlag',
    method: 'POST',
    data: {
      proid,
      type,
      state
    }
  })
}
